package org.gao.service.impl;

import org.gao.domain.Department;
import org.gao.mapper.DepartmentMapper;
import org.gao.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Transactional
    @Override
    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    @Transactional
    @Override
    public void delete(Serializable id) {

        departmentMapper.delete(id);
//        System.out.println(1/0);
    }

    @Transactional
    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }

    @Override
    public Department selectById(Serializable id) {
        return departmentMapper.selectById(id);
    }
}
